;zgbspe.du
;avance-version (13/08/01)
;1D sequence
;band selective excitation using perfect echo with 180° selective pulses;
;signal presaturation by pulsed presat or changing frequencies and
;an optional 13C decoupling

;G. Peat, P.J. Boaler, C.L. Dickson, G.C. Lloyd-Jones & D. Uhrin, Nat. Commun., 2023 

;solvent suppression based on
;Kew, W., Bell, N.G.A. Goodall, I., Uhrin, D., Magn. Reson. Chem. 55, 785-796, (2017)

;For mutli-resonance suppression use Multi-reson-suppress.xlsx and PresatOptimise.jl to optimise p23 and o1

;band selective excitation based on perfect echo
;J. A. Aguilar, M. Nilsson, G. Bodenhausen and G. A. Morris, Chem. Commun., 2012, 48, 811
 
;$CLASS=HighRes
;$DIM=1D
;$TYPE=
;$SUBTYPE=
;$COMMENT=

prosol relations=<triple>

#include <Avance.incl>
#include <Grad.incl>
#include <Delay.incl>

"d11=30m"
"d12=20us"

# ifdef PURGE
"d13=4u"
"acqt0=-p1*2/3.1416"
# else
"d13=de"
"d14=d13+p1*2/PI-de"
"acqt0=0"
baseopt_echo
# endif

# ifdef PULSED_PRESAT
"FACTOR1=(d1/(p23)) + 0.5"
"l6=FACTOR1"
# endif

1 ze

# ifdef C13_DEC
  d12 pl12:f2
# endif

2 d11
  50u BLKGRAD

# ifdef PRESAT

# ifdef C13_DEC
  d12 cpds2:f2
# endif

# ifdef PULSED_PRESAT
  d12 pl0:f1
3 (p23:sp23 ph29):f1
  2u
  lo to 3 times l6
  d12 pl1:f1
# endif

#ifdef PRESAT_JUMP 	
  d12  fq=cnst23(bf):f1 ;solvent offset in Hz
  d12 pl9:f1
  d1 cw:f1 ph29 
  4u do:f1
  d12 pl1:f1
  d12  fq=cnst24(bf):f1 ; real offset o1 in Hz
#endif

# ifdef C13_DEC
  d12 do:f2
# endif

# else
  d1 pl1:f1
#endif

  50u UNBLKGRAD

  (p1 ph1)

  d13 
  p19:gp1
  d16 pl0:f1

  4u
  (p11:sp1 ph2):f1
  4u

  p19:gp1
  d16 pl1:f1
  d13 

  (p1 ph3)
  
  d13 
  p19:gp2
  d16 pl0:f1

  4u
  (p11:sp1 ph4):f1
  4u

  p19:gp2

# ifdef PURGE
  d16 pl1:f1
  d13

# ifdef PURGE1
  p1 ph5
  4u
  p19:gp3
  d16
  p1 ph6
# endif

# ifdef PURGE2
  p1 ph5
  4u
  10u gron0
  (p32:sp29 ph1):f1
  20u groff
  d16
  p16:gp3
  d16 pl1:f1
  p1 ph6
# endif

# else
  d16
  d14
# endif

  go=2 ph31
  d11 mc #0 to 2 F0(zd)

# ifdef PURGE
 4u BLKGRAD
# endif

exit

ph1=0 0 2 2
ph2=1 1 1 1 3 3 3 3
ph3=1 3
ph4=1 1 1 1 3 3 3 3
ph5=0
ph6=2
ph29=0
ph31=0 0 2 2  

;for presat set zgoptns -DPRESAT -DPULSED_PRESAT or zgoptns -DPRESAT -DPRESAT_JUMP 	
;for selective 13C decoupling zgoptns -DC13_DEC
;for z-filter set zgoptns -DPURGE -DPURGE1 or zgoptns -DPURGE -DPURGE2

; -DPURGE1:
; 2 scans improve signal suppression outside of the excited region
; 4 scans makes it even better, no improvements with 8 scans
; 1 scan, slight signal distortions in the excited area
; 2,4, or 8 scans: inphase signals in the excited area 

; -DPURGE2: removes distortions with NS=1 (a small PFG distortions may appear) 
; Outside signals well suppressed but ~ 15% signal loss compared to PURGE1
; NS=2 little change compared to NS=1 

;p23 : ~50 ms low power rectangular pulse
;if off-resonance, calculate its exact length as desctiben in the Supplementary Information 

;if only one signal needs to be suppressed:
;SPNAM23 : Squa100.1000
;SPOFFS23 : resonance frequency of the suppressed signal minus o1 [Hz]
;spdb23 : use minimum power start with 60dB, asses the result

;if multiple signals need to be suppressed use Multi-reson-suppress.xlsx and PresatOptimise.jl to optimise p23 and o1
;create a phase-ramped shape using the calulated pulse length and the distances from o1
;prepare a rectangular shape and place it into the user library, e.g. Squa100.1000 (100us, 1000 points)
;on a topspin command line type:
;st manipulate /opt/topspin4.1/exp/stan/nmr/lists/wave/user/Squa100.1000 offs e 68936 3 565.73 -580.27 -754.27
;this will OVERWRITE the Squa100.1000 shape in /opt/topspin4.1/exp/stan/nmr/lists/wave/user/
;creating a 68936 us shape that will irradiate at 565.73, -580.27 and -754.27Hz away from optimised o1
;Note: for n frequencies replace 3 with n
;spdb23 : use minimum power, start with 60dB, asses the result. For every addtional frequency adjust by subtracting 6dB.

;if zgoptns -DC13_DEC:
;o2p : 13C chemical shift of the suppressed solvent signal
;pldb12 : power level for 13C decoupling
;at least 12dB weaker than regular decoupler power
;pcpd2 : around 200us for selective decoupling
;cpdprg2 : xy32 or garp4

;DIGMOD = baseopt
;p1 : f1 channel -  90 degree high power pulse
;pldb1 : f1 channel -  high power 
;pl1 : f1 channel - power level for the p1 pulse

;p11: f1 channel - 180 degree shaped pulse (Reburp.1000)   [0.5-3 msec]
;pl9 : f1 channel - power level for presaturation [~55-69dB]
;sp1:f1 channel - 180 degree shaped pulse (Reburp.1000)   [0.5-3 msec]
;spnam1: Reburp.1000 
;spdb1: power level for sp1

;d1 : relaxation delay; 1-5 * T1
;d12: delay for power switching                         [20 usec]
;d16: delay for homospoil/gradient recovery		[200 usec]
;ns: 1 * n, total number of scans: NS * TD0
;ds: 4
;p19: 600us homospoil/gradient pulse 
;p16:  1ms  homospoil/gradient pulse 

;for zgoptns -DPRESAT_JUMP set 
;cnst23: signal to be suppressed [Hz]
;cnst24: o1 [Hz]

;for zgoptns -DPURGE2 set 
;sp29: f1 channel - shaped pulse (adiabatic)
;p32: f1 channel - 180 degree shaped pulse (adiabatic)    [20 msec]
;     smoothed chirp (sweep width, 20% smoothing, 10000 points)
;for z-only gradients:
;gpz0: ca. 11%
;gpz1: 7%
;gpz2: 5%
;gpz3: -12%

;use gradient files:
;gpnam1: SMSQ10.100
;gpnam2: SMSQ10.100
;gpnam3: SMSQ10.100


;$Id: zgesgppe,v 1.1 2013/08/30 09:42:08 ber Exp $
